home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ian & Stuart's Australian Mac 1
/
Ian and Stuart's One (Australia).iso
/
Australasian Legends
/
Commercial
/
Rainbow Hill
/
MacDOS™ 2.0.0
/
batches
/
ls.bat
< prev
next >
Wrap
DOS Batch File
|
1993-10-30
|
3KB
|
114 lines
@echo off
! ls.bat Batch file to accept a UNIX-like ls command
!
! Call ls as follows:
!
! ls [opts] [rest]
!
! where: opts = a single argument which groups one or more of the following UNIX options:
! -l list in long format
! -t sort by time (latest first)
! -a list all entries (including hidden files)
! -r reverse order of sort (oldest first or reverse alphabetic)
! Note that only one one initial dash is expected. That is, -at is ok,
! while -a-t is not. Also "-a -t" is wrongly interpreted.
! if 'opts' is missing, ls behaves like DIR.
! rest = a series of up to 8 parameters like you would pass to DIR. This
! includes the [wildcarded] file/folder name.
!
! WARNING: if you interrupt the batch with CNTL-C, you might like to reset the system
! CMDDIR by typing "set dircmd=".
!
! Copyright © 1993 by Rainbow Hill Pty Ltd. All rights reserved.
!
!set up the environment
onerror ERR_LBL
set FIRST=*
set XT=0
set XR=0
set XDIRCMD=%DIRCMD%
set DIRCMD=/-P/W/A:-HDXF/-O/-S/-B/-L
! check the first parameter
if "%1x" == x goto DODIR_LBL
set XREST=%1x
! let's remove the first character (ie. the dash) from 'XREST'
decr -XREST
! and now we remove the "dashless" first parameter from a full copy of it, so that
! we are left with the dash itself
! The 'y' is needed to prevent 'decr' from removing 'TMP' when the dash is not
! followed by any character.
set TMP=y%1x
decr TMP by %XREST%
if not %TMP% == y- goto NOOPT_LBL
! check for the presence of something after the dash
if %XREST% == x goto NOOPT_LBL
! process one option at a time
repeat OPT_LOOP_LBL
! isolate the first character
! now 'XREST' contains at least the 'x' that we have appended to %1 when we created 'XREST'
set TMP=%XREST%
!let's remove the first character (ie. the option character) from 'XREST'
decr -XREST
! here we do what we did to isolate the dash, but we do not need to prepend a 'y'
! because we know that 'TMP' contains at least two characters and 'XREST' one
decr TMP by %XREST%
! we are now ready to process the option character
if not %TMP% == l goto END_L_LBL
set DIRCMD=%DIRCMD%/-w
goto NEXT_OPT_LBL
:END_L_LBL
if not %TMP% == t goto END_T_LBL
set XT=1
goto NEXT_OPT_LBL
:END_T_LBL
if not %TMP% == a goto END_A_LBL
set DIRCMD=%DIRCMD%/ah
goto NEXT_OPT_LBL
:END_A_LBL
if not %TMP% == r goto END_R_LBL
set XR=1
goto NEXT_OPT_LBL
:END_R_LBL
echo Invalid unix option (%TMP%). Valid options are: ltar
goto RET_LBL
:NEXT_OPT_LBL
if %XREST% == x goto BREAK_LBL
:OPT_LOOP_LBL
:BREAK_LBL
if %XT% == 0 goto NO_XT_LBL
set TMP=-d
if %XR% == 1 set TMP=d
set DIRCMD=%DIRCMD%/o%TMP%
goto DODIR_LBL
:NO_XT_LBL
set TMP=n
if %XR% == 1 set TMP=-n
set DIRCMD=%DIRCMD%/o%TMP%
dir "%2" "%3" "%4" "%5" "%6" "%7" "%8" "%9"
goto RET_LBL
:NOOPT_LBL
set FIRST=%1
:DODIR_LBL
dir "%FIRST%" "%2" "%3" "%4" "%5" "%6" "%7" "%8" "%9"
goto RET_LBL
:ERR_LBL
show %DOSERR%
onerror
:RET_LBL
set DIRCMD=%XDIRCMD%
set FIRST=
set XT=
set XR=
set XDIRCMD=
set XREST=
set TMP=